package fragments.shopadapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.travel.R;

import java.util.List;

import shopbean.ShopBean;

/**
 * 商城模块的第一个 GridView
 * Created by Administrator on 2016/10/18.
 */
public class ShopGriOneAdapter extends BaseAdapter {
    private Context context;
    private List<ShopBean.DataBean.TypeListBean> typeListBeen;

    public ShopGriOneAdapter(Context context, List<ShopBean.DataBean.TypeListBean> typeListBeen) {
        this.context = context;
        this.typeListBeen = typeListBeen;
    }

    @Override
    public int getCount() {
        return typeListBeen.size();
    }

    @Override
    public Object getItem(int i) {
        return typeListBeen.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }
    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder mHolder;
        if (view==null){
            view= LayoutInflater.from(context).inflate(R.layout.shop_gridview1_item,viewGroup,false);
            mHolder=new ViewHolder();
            mHolder.shop_gvOne_iv= (ImageView) view.findViewById(R.id.shop_gvOne_iv);
            mHolder.shop_gvOne_tv= (TextView) view.findViewById(R.id.shop_gvOne_tv);
            view.setTag(mHolder);
        }else{
            mHolder= (ViewHolder) view.getTag();
        }
        mHolder.shop_gvOne_tv.setText(typeListBeen.get(i).getName());
        Glide.with(context).load(typeListBeen.get(i).getPic())
                .into(mHolder.shop_gvOne_iv);
        return view;
    }
    static  class ViewHolder{
        ImageView shop_gvOne_iv;
        TextView shop_gvOne_tv;
    }
}
